package org.jeecg.modules.wmhb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.wmhb.entity.WmProjectStatistic;
import org.jeecg.modules.wmhb.entity.WmTaskbook;
import org.jeecg.modules.wmhb.mapper.WmProjectStatisticMapper;
import org.jeecg.modules.wmhb.service.IWmProjectStatisticService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 项目燃尽图
 * @Author: jeecg-boot
 * @Date:   2024-11-05
 * @Version: V1.0
 */
@Service
public class WmProjectStatisticServiceImpl extends ServiceImpl<WmProjectStatisticMapper, WmProjectStatistic> implements IWmProjectStatisticService {
    @Override
    public WmProjectStatistic getDateStatistic(String date, String wmProjectId, String wmContractId){
        LambdaQueryWrapper<WmProjectStatistic> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WmProjectStatistic::getDate, date);
        if(!StringUtils.isEmpty(wmProjectId)){
            queryWrapper.eq(WmProjectStatistic::getWmProjectId, wmProjectId);
        }
        if(!StringUtils.isEmpty(wmContractId)){
            queryWrapper.eq(WmProjectStatistic::getWmContractId, wmContractId);
        }
        queryWrapper.last("LIMIT 1");
        WmProjectStatistic wmProjectStatistic = getOne(queryWrapper);
        return wmProjectStatistic;
    };

    @Override
    public List<WmProjectStatistic> getByProject(String wmProjectId){
        List<WmProjectStatistic> wmProjectStatisticList = baseMapper.getByProject(wmProjectId);
        return wmProjectStatisticList;
    };
}
